package service;


import java.util.List;

import dao.GradeDAO;
import dao.StudentDAO;
import entity.Course;
import entity.Grade;



public class GradeService {
	private GradeDAO gradeDAO = new GradeDAO();
	private StudentDAO studentDAO=new StudentDAO();

	public Grade findById(Integer id) {
		return gradeDAO.findById(id);
	}

	public List<Grade> findAll() {
		return gradeDAO.findAll();
	}

	public void delete(Integer id) {
		gradeDAO.delete(id);
	}

	public void save(Grade grade) {
		Integer id = grade.getId();
		if (id == null) {
			gradeDAO.insert(grade);
		} else {
			gradeDAO.update(grade);
		}
	}
	public void delete(Grade grade) {
		gradeDAO.delete(grade.getId());
	}

	public List<Grade> findByStudentId(Integer stuId) {
		return gradeDAO.findByStudentId(stuId);
		
	}

	public Grade findByStudentIdAndCourseId(Integer studentId, Integer courseId) {
		return gradeDAO.findByStudentIdAndCourseId(studentId,courseId);
		
	}

	public List<Course> findCourseByBjId(Integer bjId) {
		return gradeDAO.findCourseByBjId(bjId);
	}

	public List<List<Object>> getCjb(Integer bjId, List<Course> courses) {
		
		return gradeDAO.getCjb(bjId,courses);
	}
}
